/*
 * Copyright 2007 www.luzand.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Prompt Service Wrapper/Helper
 */
function yrprxPromptHelper()
{
    this.BUTTON_POS_0 = Components.interfaces.nsIPromptService.BUTTON_POS_0;
    this.BUTTON_POS_1 = Components.interfaces.nsIPromptService.BUTTON_POS_1;
    this.BUTTON_POS_2 = Components.interfaces.nsIPromptService.BUTTON_POS_2;
    this.BUTTON_TITLE_OK = Components.interfaces.nsIPromptService.BUTTON_TITLE_OK;
    this.BUTTON_TITLE_CANCEL = Components.interfaces.nsIPromptService.BUTTON_TITLE_CANCEL;
    this.BUTTON_TITLE_YES = Components.interfaces.nsIPromptService.BUTTON_TITLE_YES;
    this.BUTTON_TITLE_NO = Components.interfaces.nsIPromptService.BUTTON_TITLE_NO;
    this.BUTTON_TITLE_SAVE = Components.interfaces.nsIPromptService.BUTTON_TITLE_SAVE;
    this.BUTTON_TITLE_DONT_SAVE = Components.interfaces.nsIPromptService.BUTTON_TITLE_DONT_SAVE;
    this.BUTTON_TITLE_REVERT = Components.interfaces.nsIPromptService.BUTTON_TITLE_REVERT;
    this.BUTTON_TITLE_IS_STRING = Components.interfaces.nsIPromptService.BUTTON_TITLE_IS_STRING;
    this.BUTTON_POS_0_DEFAULT = Components.interfaces.nsIPromptService.BUTTON_POS_0_DEFAULT;
    this.BUTTON_POS_1_DEFAULT = Components.interfaces.nsIPromptService.BUTTON_POS_1_DEFAULT;
    this.BUTTON_POS_2_DEFAULT = Components.interfaces.nsIPromptService.BUTTON_POS_2_DEFAULT;
    this.BUTTON_DELAY_ENABLE = Components.interfaces.nsIPromptService.BUTTON_DELAY_ENABLE;
    this.STD_OK_CANCEL_BUTTONS = Components.interfaces.nsIPromptService.STD_OK_CANCEL_BUTTONS;
    this.STD_YES_NO_BUTTONS = Components.interfaces.nsIPromptService.STD_YES_NO_BUTTONS;
}

yrprxPromptHelper.prototype = {
    get promptService()
    {
        if (!this._promptService)
            this._promptService = yrprxComponentsFactory.getPromptService();
        return this._promptService;
    }
}

yrprxPromptHelper.prototype.alert = function (title, message)
{
    this.promptService.alert(null, title, message);
}

yrprxPromptHelper.prototype.confirmEx = function (dialogTitle, text, buttonFlags, button0Title, button1Title, button2Title, checkMsg, checkState)
{
    if (typeof button0Title == "undefined")
        button0Title = null;
    if (typeof button1Title == "undefined")
        button1Title = null;
    if (typeof button2Title == "undefined")
        button2Title = null;
    if (typeof checkMsg == "undefined" || typeof checkState == "undefined")
    {
        checkMsg = null;
        checkState = {};
    }

    return this.promptService.confirmEx(
            null,
            dialogTitle,
            text,
            buttonFlags,
            button0Title,
            button1Title,
            button2Title,
            checkMsg,
            checkState
            );
}

var yrprxPrompt = new yrprxPromptHelper();